package my.edu.model.bills.purchase.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.Null;
import jakarta.validation.groups.Default;
import lombok.Data;
import lombok.EqualsAndHashCode;
import my.edu.common.domain.OrderProductDetail;
import my.edu.common.enumeration.OrderType;
import my.edu.common.validate.groups.Insert;
import my.edu.common.validate.groups.Sales;

import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.Objects;

// 让PurchaseOrderDetail继承OrderProductDetail
@Data
@EqualsAndHashCode(callSuper = true, onlyExplicitlyIncluded = true)
@TableName("purchase_order_detail")
public class PurchaseOrderDetail extends OrderProductDetail {
    @EqualsAndHashCode.Include
    private Long productId;
    @TableId(type = IdType.AUTO)
    private Long id;
    private Long purchaseOrderId;
    private BigDecimal purchasePrice; // 购货单价
    private Integer wholePackage; // 整件散包
    private BigDecimal procurementCost; // 采购费用
    private String remark;
    private Long warehouseId;
    private String warehouseName;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(fill = FieldFill.INSERT)
    private LocalDateTime createTime;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @TableField(fill = FieldFill.UPDATE)
    private LocalDateTime updateTime;
    @TableField(fill = FieldFill.UPDATE)
    private Long updatedBy;

    @Override
    public BigDecimal getCurrentPrice() {
        return getPurchasePrice();
    }

    @Override
    public void setCurrentPrice(BigDecimal price) {
        setPurchasePrice(price);
    }

    @Override
    public OrderType getCurrentOrderType() {
        return OrderType.PURCHASE_PRICE;
    }


}